<?php
	$publicKey = "-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8/OUkY6ES9WkmgY7+voc
H0KGj3gr8W64LhgjPxEWh7wdoYSYw2VNz2agbf4vlmmgO2yArf3woXRGMWIsyjZd
UnJWOQVL1l+KsUaG82xXNlP+Wu7DfJsRa2k2S/1SKfLAIItABTpzToJu35NIt3wS
pECWSQNzJWbUHLuS7w5Gn2fqI/IgKXdzrvoblgjmjokxyMNfLnBiZAesKZOfbBCV
lATBgEW8jFK5+q8P2tub2sms51ei6OGCx8Va7+1TIcbxiSI1y8dwclwooFgfLt4K
5307BWKd7PVkl82BlpEyY5iK+7QqqCJB/10+B6kiUqVBKDWgq9WbnnAZXslznRHx
EwIDAQAB
-----END PUBLIC KEY-----
";
	$privateKey = "-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDz85SRjoRL1aSa
Bjv6+hwfQoaPeCvxbrguGCM/ERaHvB2hhJjDZU3PZqBt/i+WaaA7bICt/fChdEYx
YizKNl1SclY5BUvWX4qxRobzbFc2U/5a7sN8mxFraTZL/VIp8sAgi0AFOnNOgm7f
k0i3fBKkQJZJA3MlZtQcu5LvDkafZ+oj8iApd3Ou+huWCOaOiTHIw18ucGJkB6wp
k59sEJWUBMGARbyMUrn6rw/a25vayaznV6Lo4YLHxVrv7VMhxvGJIjXLx3ByXCig
WB8u3grnfTsFYp3s9WSXzYGWkTJjmIr7tCqoIkH/XT4HqSJSpUEoNaCr1ZuecBle
yXOdEfETAgMBAAECggEBAKMXR04Af4XLcN3gKR1jNIXZjehAqPAh21RFotq4690W
8KBY62BGS7zKmZqvgtUGDK9tnKG10be+6mZ9ggA2VDGYavh4B/lrqmdWBUacOboC
cVwNn/egHAc5Mamf09xjg/q93bEhIJFuNf2Wk9jHRBc3bsGlYsewdUI4TMUxQBm0
qvGrqNlcyNWbkf+OZ8pXRLAEb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_get_private($privateKey);//这个函数可用来判断私钥是否是可用的，可用返回资源id Resource id
	$pu_key = openssl_pkey_get_public($publicKey);//这个函数可用来判断公钥是否是可用的
	
	function rsaInfo($user, $password){ // 账户解析
		global $pi_key;
		$rsauser = '';
		$rsapassword = '';
		openssl_private_decrypt(base64_decode($user), $rsauser, $pi_key);
		openssl_private_decrypt(base64_decode($password), $rsapassword, $pi_key);
		$userInfo = array(
			"user" => $rsauser,
			"password" => $rsapassword
		);
		return $userInfo;
	}
	function registers ($user, $password, $enterpriseName) {
		global $pi_key;
		$rsauser = '';
		$rsapassword = '';
		$rsaenterpriseName = '';
		openssl_private_decrypt(base64_decode($user), $rsauser, $pi_key);
		openssl_private_decrypt(base64_decode($password), $rsapassword, $pi_key);
		openssl_private_decrypt(base64_decode($enterpriseName), $rsaenterpriseName, $pi_key);
		$registerInfo = array(
			"user" => $rsauser,
			"password" => $rsapassword,
			"enterpriseName" => $rsaenterpriseName
		);
		return $registerInfo;
	}
	function verifyUserInfo ($userObj) {
		$name = $userObj['user'];
		$sql="select * from users WHERE phone='$name'";
		$mysqlInfo = get_all($sql);
		forEach($mysqlInfo as $key => $val){
			if($val['password'] === $userObj['password']){
				$userObj = array(
					"code" => 0,
					"msg" => '验证成功',
					"data" => $mysqlInfo
				);
			}
		}
		return $userObj;
	}
?>